package config

import (
	"io/ioutil"
	"log"

	yaml "gopkg.in/yaml.v2"
)

//Dingtalk 项目配置值
var Dingtalk *DingtalkConfig

//DingtalkConfig 项目配置结构
type DingtalkConfig struct {
	AgentID   string
	AppKey    string
	AppSecret string
}

//Init 配置初始化
func Init(cf *string) {
	Dingtalk = new(DingtalkConfig)
	yamlFile, err := ioutil.ReadFile(*cf)
	if err != nil {
		log.Printf("yamlFile.Get err #%v ", err)
	}
	err = yaml.Unmarshal(yamlFile, Dingtalk)
	if err != nil {
		log.Fatalf("Unmarshal: %v", err)
	}
}
